{extend name="base/common"}

{block name="style"}
<link href="/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
<!-- Sweet Alert -->
<link href="/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<!-- Ladda style -->
<link href="/admin/css/plugins/ladda/ladda-themeless.min.css" rel="stylesheet">
{/block}

{block name="page-header"}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>部门管理</h2>
        <ol class="breadcrumb">
            <li>
                <a>通讯录</a>
            </li>
            <li class="active">
                <strong>部门列表</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">

    </div>
</div>
{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>部门列表</h5>
                    <div class="ibox-tools progress-demo">
                        <button class="ladda-button ladda-button-user-one btn btn-primary"  data-style="zoom-in">一键同步</button>
                        <button class="ladda-button ladda-button-user btn btn-primary"  data-style="zoom-in">同步部门</button>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <!--<th><input class="i-checks check-all" type="checkbox"></th>-->
                                    <th>ID</th>
                                    <th>名称</th>
                                    <!--<th>操作</th>-->
                                </tr>
                            </thead>
                            <tbody>
                                {volist name="list" id="vo"}
                                <tr>
                                    <!--<td><input type="checkbox" class="i-checks ids" name="input[]"></td>-->
                                    <td>{$vo.id}</td>
                                    <td>{$vo.name}</td>
                                    <!--<td>查看详情</td>-->
                                </tr>
                                {/volist}
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="11">
                                    <div class="page">{$list->render()}</div>
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="/admin/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/admin/js/plugins/ladda/spin.min.js"></script>
<script src="/admin/js/plugins/ladda/ladda.min.js"></script>
<script src="/admin/js/plugins/ladda/ladda.jquery.min.js"></script>
<script>
    highlight_subnav("{:Url('Wechat/department')}");

    $(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });
        $(".check-all").on("ifChanged",function(){
            $("tbody").find(".ids").iCheck("toggle");
        });

        var one = $( '.ladda-button-user-one' ).ladda();
        one.click(function(){
            one.ladda( 'start' );
            $.ajax({
                type: "get",
                url: "{:Url('Wechat/oneclicksync')}",
                data: {type:0},
                success: function (response) {
                    swal(response.msg, response.data);
                    one.ladda('stop');
                    window.location.reload();
                },
                error: function (err) {
                    one.ladda('stop');
                }
            });
        });

        var l = $( '.ladda-button-user' ).ladda();
        l.click(function(){
            l.ladda( 'start' );
            $.ajax({
                type: "get",
                url: "{:Url('Wechat/oneclicksync')}",
                data: {type:2},
                success: function (response) {
                    swal(response.msg, response.data);
                    l.ladda('stop');
                    window.location.reload();
                },
                error: function (err) {
                    l.ladda('stop');
                }
            });
        });
    });
</script>
{/block}